package ws

import (
	"github.com/gin-gonic/gin"
	"github.com/gorilla/websocket"
	"time"
)

type SessionBuilder struct {
	ReadIdleTimeout  time.Duration // 读超时
	WriteIdleTimeout time.Duration // 写超时(单位：秒)
	IdleTimeout      time.Duration // 空闲超时(单位：秒)
	WriteQueueSize   uint          // 读消息队列缓冲大小
	ReadQueueSize    uint          // 写消息队列缓冲大小
}

func (x *SessionBuilder) build(ws *websocket.Conn, handle ISessionHandle, ctx *gin.Context) *Session {
	session := NewSession(ws, handle, ctx)
	session.idleTimeout = x.IdleTimeout
	session.writeIdleTimeout = x.WriteIdleTimeout
	session.readIdleTimeout = x.ReadIdleTimeout
	return session
}

func NewSessionBuilder() *SessionBuilder {
	return &SessionBuilder{}
}
